#include <iostream>
#include <limits>
#include <vector>
#include <cmath>

using namespace std;

class Graph{
public:
    void scan(int n) {
        AdjMatrix.resize(n);
        for(size_t i=0; i<n; ++i) AdjMatrix[i].resize(n);

        double scanned_price;
        for (size_t i=0; i<n; ++i)
            for (size_t j=0; j<n; ++j) {
                cin>>scanned_price;
                AdjMatrix[j][i]=-log(scanned_price);
            }
    }
    Graph () {
        for (size_t i=0; i<AdjMatrix.size(); ++i)
            for (size_t j=0; j<AdjMatrix.size(); ++j)
                AdjMatrix[i][j]=std::numeric_limits<double>::infinity();
    }

    bool Bellman_Ford(int s) {
        d_array.resize(AdjMatrix.size());
        pi_array.resize(AdjMatrix.size());
        for (size_t i=0; i<AdjMatrix.size(); ++i) {
            d_array[i]=std::numeric_limits<double>::infinity();
            pi_array[i]=std::numeric_limits<double>::infinity();
        }
        d_array[s]=0;

        for (size_t i=0; i<AdjMatrix.size()-1; ++i) {
            for (size_t j=0; j<AdjMatrix.size(); ++j) {
                for (size_t k=0; k<AdjMatrix.size(); ++k) {
                    Relax(k, j);
                }
            }
        }

        for (size_t i=0; i<AdjMatrix.size(); ++i)
            for (size_t j=0; j<AdjMatrix.size(); ++j)
                if ( (d_array[j]) > (d_array[i]) + AdjMatrix[i][j] && AdjMatrix[i][j]!=std::numeric_limits<double>::infinity() ) {
                    int failed_vertex=i;
                    do {
                        cout<<failed_vertex+1<<" ";
                        failed_vertex=pi_array[failed_vertex];
                    } while(failed_vertex!=i);
                    cout<<failed_vertex+1;
                    return false;
                }
        cout<<"No";
        return true;
    }
private:
    bool Relax (int u, int v) {
        if ( AdjMatrix[u][v]==std::numeric_limits<double>::infinity() ) return false;
        if ( (d_array[v]) > (d_array[u]) + AdjMatrix[u][v] ) {
            d_array[v] = d_array[u] + AdjMatrix[u][v];
            pi_array[v] = u;
        }
        return true;
    }
    vector< vector<double> > AdjMatrix;
    vector<double> pi_array;
    vector<double> d_array;
};

int main() {
    if(freopen("in.txt", "r", stdin)==NULL) {
        cout<<"Error: input file can't be opened";
        return 1;
    }
    if(freopen("out.txt", "w", stdout)==NULL) {
        cout<<"Error: output file can't be opened";
        return 1;
    }
    int n;
    cin>>n;

    if(n<=0) {
        cout<<"Error: wrong count of values";
        return 1;
    }

    Graph G;
    G.scan(n);
    G.Bellman_Ford(0);

    return 0;
}